package com.ruoyi.system.controller.mine;


import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.Education;
import com.ruoyi.system.service.IEducationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 学历信息
 *
 * @author ruoyi
 * @date 2023-10-09
 */
@RestController
@RequestMapping("/education")
public class EducationController extends BaseController
{
    @Autowired
    private IEducationService educationService;

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("mine:education:list")
    @GetMapping("/list")
    public TableDataInfo list(Education education)
    {
        startPage();
        List<Education> list = educationService.selectEducationList(education);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("mine:education:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Education education)
    {
        List<Education> list = educationService.selectEducationList(education);
        ExcelUtil<Education> util = new ExcelUtil<Education>(Education.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @RequiresPermissions("mine:education:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(educationService.selectEducationById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @RequiresPermissions("mine:education:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Education education)
    {
        return toAjax(educationService.insertEducation(education));
    }

    /**
     * 修改【请填写功能名称】
     */
    @RequiresPermissions("mine:education:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Education education)
    {
        return toAjax(educationService.updateEducation(education));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("mine:education:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(educationService.deleteEducationByIds(ids));
    }
}
